<script type="text/javascript">
//自动有效日期
$(document).on('afterchange.bjui.datepicker', '.j_custom_issuedate', function(e, data) {
    var pattern = 'yyyy-MM-dd'
    var start   = end = data.value
    var $end    = $(this).closest('tr').find('.j_custom_indate')
    
    if ($end.length) {
        end.setFullYear(start.getFullYear() + 10)
        end.setDate(start.getDate() - 1)
        $end.val(end.formatDate(pattern))
    }
})
//上传图片完成回调
function custom_pic_upload_success(file, data, $upload) {
    var json = $.parseJSON(data)
    if (json[BJUI.keys.statusCode] == BJUI.statusCode.ok) {
        var pic = json.navTabId
        
        $upload.next().val(pic).next().html('<img src="'+ pic +'" width="80" />')
    }
}
//删除回调
$('#spectable').on('afterdelete.bjui.tabledit', function(e) {
    var $tbody = $(e.relatedTarget)
    
    console.log('你删除了一条数据，还有['+ $tbody.find('> tr').length +']条数据！')
})
</script>

<div class="bjui-pageHeader">
  <form id="pagerForm" data-toggle="ajaxsearch" action="{:U('index')}" method="post">
    <div class="bjui-searchBar">
      <div class="alert alert-info search-inline"><i class="fa fa-info-circle"></i> 双击行可编辑</div>
      <button type="button" class="btn-green" data-toggle="tableditadd" data-target="#spectable" data-num="1" data-icon="plus">添加规格</button>
    </div>
  </form>
</div>
<div class="bjui-pageContent tableContent">
  <form action="{:U('add')}" id="j_custom_form" class="pageForm" data-toggle="validate" method="post">
    <table id="spectable" class="table table-bordered table-hover table-striped table-top" data-toggle="tabledit" data-initnum="0" data-action="{:U('update')}" data-single-noindex="true"  data-selected-multi="true">
      <thead>
        <tr data-idname="customList[#index#][brand_id]">
          <th title="排序" width="50"><input type="text"  name="customList[#index#][sort]"  class="no" data-rule="required" ></th>
          <th title="规格"><input type="text" name="customList[#index#][name]" data-rule="required" size="5"></th>
          <th title="规格代码"><input type="text" name="customList[#index#][code]" data-rule="required" size="5"></th>
          <th title="" data-addtool="true" width="100"> 
		  <a href="{:U('remove?delrow=1')}" class="btn btn-red row-del" data-confirm-msg="确定要删除该行信息吗？">删</a> 
		  </th>
        </tr>
      </thead>
      <tbody>
        <notempty name="_list">
          <volist name="_list" id="vo">
            <tr data-id="{$vo.brand_id}">
              <td data-id-val="{$vo.brand_id}">{$vo.brand_id}</td>
              <td>{$vo.brand_name}</td>
              <td data-noedit="true"><button type="button" class="btn-green" data-toggle="doedit">编辑</button></td>
              <td data-noedit="true"><a href="{:U('remove?id='.$vo['brand_id'])}" class="btn btn-red row-del" data-confirm-msg="确定要删除该行信息吗？">删</a> </td>
              <td style="display: none;">{$vo.brand_id}</td>
            </tr>
          </volist>
        </notempty>
      </tbody>
    </table>
  </form>
</div>
<div class="bjui-pageFooter">
  <ul>
    <li>
      <button type="button" class="btn-close" data-icon="close">取消</button>
    </li>
    <li>
      <button type="submit" class="btn-default" data-icon="save">全部保存</button>
    </li>
  </ul>
</div>
